// components/tabbar/tabbar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    active:{
      type:String,
      value:'service'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    active: 'service',
    imgPath: "/images",
    beforePlanned:false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
    // console.log("onChange",event)
  //   console.log("event.detailevent.detailevent.detail",event.detail)

      this.setData({
        active: event.detail
      });

      //设置tabbar激活项
      const util = require("../../utils/util")
    //  console.log('this.data.active',this.data.active);
      util.setTabbarActive(this.data.active)

      //触发事件
      this.triggerEvent("onChange", this.data.active)
    },
  },
  lifetimes: {
    attached() {
      //取得tabbar激活项
      const util = require("../../utils/util")
      this.setData({
        active: util.getTabtarActive(),
        imgPath: util.getImgPath(),
        beforePlanned:util.getBeforePlanned()
      })

      // console.log("tabbar,this.data.imgPath",this.data.imgPath)
    }
  }
})